import { uiProperties, uiStyleProperties } from './common'

// input
export const inputProperties = [
    ...uiProperties.filter(e => ['ui.placeholder', 'ui.clearable', 'ui.readonly'].indexOf(e.model) !== -1),
    ...uiStyleProperties.filter(e => ['ui.style.width'].indexOf(e.model) !== -1),
    {
        model: 'ui.readonly',
        widget: 'switch',
        label: '只读'
    },
    {
        model: 'ui.minlength',
        widget: 'inputNumber',
        label: '最小长度',
        ui: {
            placeholder: '请输入最小长度',
            min: 0,
            max: 99999999,
            precision: 0,
            controlsPosition: 'right',
            style: {
                width: '100%'
            }
        }
    },
    {
        model: 'ui.maxlength',
        widget: 'inputNumber',
        label: '最大长度',
        ui: {
            placeholder: '请输入最大长度',
            min: 0,
            max: 99999999,
            precision: 0,
            controlsPosition: 'right',
            style: {
                width: '100%'
            }
        }
    },
    {
        model: 'ui.showWordLimit',
        widget: 'switch',
        label: '统计'
    },
    {
        model: 'ui.type',
        widget: 'select',
        label: '类型',
        enum: [
            { label: '文本框', value: 'text' },
            { label: '多行文本', value: 'textarea' },
            { label: '密码框', value: 'password' },
            { label: '数字框', value: 'number' }
        ],
        ui: {
            placeholder: '请选择类型',
            clearable: true,
            style: {
                width: '100%'
            }
        }
    },
    {
        model: 'ui.showPassword',
        widget: 'switch',
        label: '显示切换密码'
    },
    {
        model: 'ui.min',
        widget: 'input',
        label: '最小',
        ui: {
            placeholder: '请输入数字',
            type: 'number'
        },
        if (model) {
            return model && model.ui && model.ui.type === 'number'
        }
    },
    {
        model: 'ui.max',
        widget: 'input',
        label: '最大',
        ui: {
            placeholder: '请输入数字',
            type: 'number'
        },
        if (model) {
            return model && model.ui && model.ui.type === 'number'
        }
    },
    {
        model: 'ui.step',
        widget: 'input',
        label: '步长',
        ui: {
            placeholder: '请输入数字',
            type: 'number'
        },
        if (model) {
            return model && model.ui && model.ui.type === 'number'
        }
    }
]
